// Universal Asynchronous Receiver/Transmitter
#include "register.h"

DEFINE_SYS_WRITE(VBAR_EL1)

DEFINE_SYS_READ(ESR_EL1)

extern void* exceptions_el1;

vector_el1_init(){
    if(((unsigned long int)&exceptions_el1 % 0x800) != 0){
        printk("error");
        return;
    }
    sys_write_VBAR_EL1(&exceptions_el1);
    printk("exception_el1 is: %x \n", &exceptions_el1);

}


// sp0
void current_el_sp0_sync_handler(){
    printk("this is current_el_sp0_sync_handler\n");
}

void current_el_sp0_irq_handler(){
    printk("this is current_el_sp0_irq_handler\n");
}

void current_el_sp0_fiq_handler(){
    printk("this is current_el_sp0_fiq_handler\n");
}

void current_el_sp0_serror_handler(){
    printk("this is current_el_sp0_serror_handler\n");
}

// spx
void current_el_spx_sync_handler(){
    printk("this is current_el_spx_sync_handler\n");

    // unsigned long int a = sys_read_ESR_EL1();

    // printk("a= %x\n",a);
}

void current_el_spx_irq_handler(){
    // printk("this is current_el_spx_irq_handler\n");
    gic_v2_handler();
}

void current_el_spx_fiq_handler(){
    printk("this is current_el_spx_fiq_handler\n");
}

void current_el_spx_serror_handler(){
    printk("this is current_el_spx_serror_handler\n");
}

// aarch64
void current_el_aarch64_sync_handler(){
    printk("this is current_el_aarch64_sync_handler\n");
}

void current_el_aarch64_irq_handler(){
    printk("this is current_el_aarch64_irq_handler\n");
}

void current_el_aarch64_fiq_handler(){
    printk("this is current_el_aarch64_fiq_handler\n");
}

void current_el_aarch64_serror_handler(){
    printk("this is current_el_aarch64_serror_handler\n");
}

// aarch32
void current_el_aarch32_sync_handler(){
    printk("this is current_el_aarch32_sync_handler\n");
}

void current_el_aarch32_irq_handler(){
    printk("this is current_el_aarch32_sync_handler\n");
}

void current_el_aarch32_fiq_handler(){
    printk("this is current_el_aarch32_sync_handler\n");
}

void current_el_aarch32_serror_handler(){
    printk("this is current_el_aarch32_sync_handler\n");
}